<?php
class TDGLogin{
	
	function login($email, $password){
		session_start();
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		
		$result = mysql_query("SELECT * FROM cuentasusuarios  WHERE Email = '$email' AND pass = md5('$password');");
		$num_rows = mysql_num_rows($result);
		
		if($result!=FALSE){
			$row = mysql_fetch_array($result);
			if($num_rows==1){
				$_SESSION['usuario']= $row['Permisos'];
				$_SESSION['nombre']= $row['Nombre'];
				$_SESSION['apellido']= $row['Apellidos'];
				$_SESSION['id']= $row['ID'];
				mysql_close($connection);
				return true;
			}else{
				mysql_close($connection);
				return false;
			}
		} else{
			mysql_close($connection);
			return false;
		}
	}
}
?>